﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.MaterialMasterData.Dto;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NP.BPMReportPlatform.MaterialMasterData
{
    /// <summary>
    /// 排课平台接口
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/PKPlatform")]
    public class PKPlatformController: BPMReportPlatformController
    {
        private readonly IMMDOrderService _mmdOrderService;
        private readonly IPKPlatformService _pkPlatformService;

        public PKPlatformController(IMMDOrderService mmdOrderService, IPKPlatformService pkPlatformService)
        {
            _mmdOrderService = mmdOrderService;
            _pkPlatformService = pkPlatformService;
        }

        /// <summary>
        /// 全景图月度预估导出Excel
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExportMonthPanoramExcel")]
        public async Task<FileContentResult> ExportMonthPanoramExcel([FromBody] PKMonthPanoramaInput input)
        {
            var data = await _pkPlatformService.ExportMonthPanoramExcel(input);
            var ms = new MemoryStream();
            data.Write(ms);
            data.Close();
            return File(ms.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        }

        [HttpPost]
        [Route("DeleteRecord")]
        public void DeleteRecord([FromBody] DeleteRecordInput input)
        {
            _pkPlatformService.DeleteRecord(input);
        }
    }
}
